'use strict'

define(['jquery', 'bootstrap', 'select2', 'shiftform', 'validate', 'validate.en'], function ($) {
  
  return {
    
    init: function () {
      this.initPage();
      this.initSearch();
      this.initExport();
    },
    
    initPage: function() {
      
      $(document).on('click', '#selectAll', function(e) {
        $('input[name="vehicleId"]').prop('checked', $('#selectAll').is(':checked'));
      });
      
      $(document).on('change', '#selectAll, input[name="vehicleId"]', function(e) {
        var ids = $('input[name="vehicleId"]:checked').val();
        if (ids) {
          $('a.batch-export').removeClass('disabled');
        } else {
          $('a.batch-export').addClass('disabled');
        }
      });
      
    },

    initSearch: function() {
      $(document).on('shown.bs.modal', '#search', function(e) {
      });
    },
    
    initExport: function() {
      
      $(document).on('shown.bs.modal', '#export', function(e) {
        $(e.currentTarget).find('form[data-validate="true"]').bt_validate()  //bind validate
      });
      
    }
    
  }
})